<extend name="template/base_index" />

<block name="area_header">

	<link rel="stylesheet" href="__CSS__/buysell.css">
</block>

<block name="area_body">
	<div class="head">
		<a href="{:U('UserCenter/index')}"><i class="fa fa-chevron-left"></i></a>
		<span>我买到的</span>
	</div>

	<volist name="buyinfo" id="buy">
		<div class="pro">
			<a href="{:U('Mybuysell/buydetail',array('order_code' => $buy['order_code']))}"><img src="{$buy['img']}" width="80px" height="80px"></a>
			<if condition="$buy['pay_status'] == 0">
				<ul>
					<li><span><a href="{:U('Mybuysell/buydetail',array('order_code' => $buy['order_code']))}">{$buy['name']}</a></span></li>
					<li><p>&yen;{$buy['price']}</p></li>
					<li class="gray"><i class="fa fa-clock-o"></i>待付款</li>
				</ul>
				<if condition ="$buy['grouptype'] eq 1"><a href="http://muyin.8raw.com/index.php/Home/Pay/jsapi/?order_code={$buy['order_code']}&type=tuanzhang&counttype={$buy['counttype']}&pid={$buy['p_id']}"
														 class="pro-n-act weui_btn weui_btn_mini weui_btn_default">我要付款</a>
				<elseif condition ="$buy['grouptype'] gt 1"/><a href="http://muyin.8raw.com/index.php/Home/Pay/jsapi/?order_code={$buy['order_code']}&type=tuanyuan&groupid={$buy['grouptype']}&counttype={$buy['counttype']}&pid={$buy['p_id']}"
																	class="pro-n-act weui_btn weui_btn_mini weui_btn_default">我要付款</a>


				<else/><a href="http://muyin.8raw.com/index.php/Home/Pay/jsapi/?order_code={$buy['order_code']}"
				   class="pro-n-act weui_btn weui_btn_mini weui_btn_default">我要付款</a></if>
			</if>
			<if condition="$buy['order_status'] == 3">
				<ul>
					<li><span><a href="{:U('Mybuysell/buydetail',array('order_code' => $buy['order_code']))}">{$buy['name']}</a></span></li>
					<li><p>&yen;{$buy['price']}</p></li>
					<li class="gray"><i class="fa fa-clock-o"></i>等待卖家发货</li>
				</ul>
				<a data-href="{:U('Mybuysell/apply_returnmoney',array('order_code' => $buy['order_code']))}" href="javascript:;"  class="show-confirm pro-n-act weui_btn weui_btn_mini weui_btn_default">取消订单申请退款</a>
			</if>
			<if condition="$buy['order_status'] == 8">
				<ul>
					<li><span><a href="{:U('Mybuysell/buydetail',array('order_code' => $buy['order_code']))}">{$buy['name']}</a></span></li>
					<li><p>&yen;{$buy['price']}</p></li>
					<li class="gray"><i class="fa fa-clock-o"></i>订单已取消</li>
				</ul>
			</if>

			<if condition="$buy['order_status'] == 4">
				<ul>
					<li><span><a href="{:U('Mybuysell/buydetail',array('order_code' => $buy['order_code']))}">{$buy['name']}</a></span></li>
					<li><p>&yen;{$buy['price']}</p></li>
					<li class="gray"><i class="fa fa-clock-o"></i>等待买家收货</li>
				</ul>

				<a data-href="{:U('Mybuysell/confirm_receipt',array('order_code' => $buy['order_code']))}" class="confirm-receipt pro-n-act weui_btn weui_btn_mini weui_btn_default">确认收货</a>
				<volist name="orderinfo" id="order">
					<if condition="$buy['order_code'] == $order['order_code']">
						<a href="http://m.kuaidi100.com/index_all.html?type={$order['expresscode']}&postid={$order['expressno']}" class="pro-n-act weui_btn weui_btn_mini weui_btn_default">查看物流</a>
					</if>
				</volist>
			</if>
			<if condition="$buy['order_status'] == 5">
				<ul>
					<li><span><a href="{:U('Mybuysell/buydetail',array('order_code' => $buy['order_code']))}">{$buy['name']}</a></span></li>
					<li><p>&yen;{$buy['price']}</p></li>
					<li class="gray"><i class="fa fa-check-circle"></i>交易成功</li>
				</ul>
				<volist name="orderinfo" id="order">
					<if condition="$buy['order_code'] == $order['order_code']">
						<a href="http://m.kuaidi100.com/index_all.html?type={$order['expresscode']}&postid={$order['expressno']}" class="pro-n-act weui_btn weui_btn_mini weui_btn_default">查看物流</a>
					</if>
				</volist>
			</if>
		</div>
	</volist>

	<script src="__JS__/jquery-weui.min.js"></script>
	<script>
		$(function(){
			$(".show-confirm").bind("click", function() {
				var url = $(this).attr('data-href');
				$.confirm("您确定要取消订单", function() {
					$.get(url,function(msg){
						console.log(msg);
						if(msg){
							$.toast("信息发送成功");
							window.location.reload();
						}else{
							$.toast("信息发送失败");
						}
					});

				}, function() {
					//取消操作
				});
			});
			/*确认收货*/
			$(".confirm-receipt").bind("click", function() {
				var url = $(this).attr('data-href');
				$.confirm("您确定您已经收到货了", function() {
					$.get(url,function(msg){
						if(msg){
							$.toast("确认成功");
							window.location.reload();
						}else{
							$.toast("不好意思 确认失败了");
						}
					});

				}, function() {
					//取消操作
				});
			});
		})
	</script>
</block>